#!/usr/bin/env python
# _*_ coding: utf-8 _*_
# @Time : 2022/9/15 10:54
# @Author : Violet
# @File : xiangmu.py
# @desc :
import os

from fastapi import APIRouter
from utils import resp_200
from openpyxl import load_workbook

# ---------------------------------------------美观线-------------------------------------------------------

router = APIRouter()


# dependencies=[Security(check_permissions, scopes=["user_select"])]
@router.get('/aaa', summary="表")
async def excel():
    wb = load_workbook('./models/20552910.xlsx', read_only=True, data_only=True)
    ws = wb['Sheet1']  # 拿到工作薄对象
    data_list = []
    li1 = ['name', 'phone', 'password', 'word', 'qwer']
    li2 = []
    for i in range(5, 12):
        for j in range(3, 8):
            if j < 7:
                li2.append(ws.cell(i, j).value)
            else:
                li2.append(ws.cell(i, j).value)
                data_list.append(dict(zip(li1, li2)))
                li2 = []

    return resp_200(msg="查询成功！", data=data_list)
